package com.peakmain.homemodule.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.andview.refreshview.XRefreshView;

/**
 * author: peakmain
 * createdata：2019/7/24
 * mail: 2726449200@qq.com
 * desiption:
 */
public class HomeXRecyclerView extends XRefreshView {

    float downY,downX;

    public HomeXRecyclerView(Context context) {
        super(context);
    }

    public HomeXRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {

        switch (e.getAction()) {
            case MotionEvent.ACTION_DOWN:
               downY=e.getY();
               downX=e.getX();
                break;

            case MotionEvent.ACTION_MOVE:
                float endY=e.getY();
                float endX=e.getX();
                float distanceX=endX-downX;
                float distanceY=endY-downY;
                if(distanceX>0&&distanceY>0&&distanceX<distanceY){
                  getParent().requestDisallowInterceptTouchEvent(true);
                }
                break;
            case MotionEvent.ACTION_UP:
                break;
        }
        return super.onTouchEvent(e);
    }
}
